<Script runat=server>
  Public Sub Session_Add(sender As Object, e As EventArgs)
    Session("cart") = text1.Value
    span1.InnerHtml = "Session data updated! <P>Your session contains: <font color=red>" + Session("cart") + "</font>"

    Application("foo") = 1
  End Sub

  Public Sub CheckSession(sender As Object, e As EventArgs)
    If (Session("cart") Is Nothing) Then
       span1.InnerHtml = "NOTHING, SESSION DATA LOST!"
    Else
       span1.InnerHtml = "Your session contains: <font color=red>" + Session("cart") + "</font>"
    End If

    Dim i As Integer
    i = Application("foo")
  End SUb
</Script>

<form runat=server>
<input id=text1 type=text runat=server>
<input type=submit runat=server OnServerClick="Session_Add" Value="Add to Session State">
<input type=submit runat=server OnServerClick="CheckSession" Value="View Session State">
</form>
<hr size=1>
<font size=6><span id=span1 runat=server/></font>